<?php

$bbsid=isset($_GET['id'])?$_GET['id']:0;
require 'dbcon.php';
if(empty($_POST))
{
$sql="select * from t_message where id='$bbsid'";
$rs=$db->query($sql);
$editbbs=$rs->fetch_array();
include 'edit_html.php';
}
else{
    $username=$_REQUEST['username'];
    $message=$_REQUEST['message'];
    $sql="update t_message set username'={$username}',message='{$message}' where id={$bbsid}";
    $rs=$db->query($sql);
    if ($rs==true)      //根据返回结果，做不同的响应
{   
    header("Location:index.php");//直接跳转
}
else
{
    // JavaScript弹出对话框跳转
    echo "<script language='javascript'>";
    echo "alert('留言失败！');";
    echo "window.location.href='index.php';";
    echo "</script>";
}
$db->close();
}
    
